Analyzing Bitcoin and Ethereum in the past 6 years

Meixiong Peng

Introduction

A cryptocurrency is a digital or virtual currency that is secured by cryptography, which has super high-level security. It's often used to buy goods and services and even investments. Cryptocurrency has been really popular in recent years, its value is also growing exponentially. More people starting to invest in cryptocurrency and even some country's governments like El Salvador are also involved.

The most popular cryptocurrency right now is bitcoin. Bitcoin is a digital currency that was created by an unknown group or person with the name Satoshi Nakamoto, who released the bitcoin as an open source software in 2009. It's the first decentralized digital currency which means no one can controll this currency and it's available anywhere in the world. Its current price is approximately $49,000.

The second-largest cryptocurrency right now is Ethereum, it was created in 2013 by programmer Vitalik Buterin and his group, which has a current price of around $4000. People are saying Ethereum might beat Bitcoin and become the largest cryptocurrency, But we can see there are still a large price diffence between them. Therefore, in this tutorial, I'll target Bitcoin and Ethereum specifically, and try to analyze them from a data science perspective. I'll find if there are any patterns throughout the years and find the correlation between Bitcoin and Ethereum. After that, I will use sklearn regression models and try to do some predictions about their future prices.

You can learn more about Bitcoin and Ethereum here

Cryptocurrency-Bitcoin.jpeg

Dataset

I used yahoo finance to find both bitcoin and ethereum datasets. For the data range, I was only able to get ethereum data starting from 2015-08-07 so I will drop bitcoin's data before that day so that it's easier when we are comparing them. Link below is where I got the data set:

  1. https://finance.yahoo.com/quote/BTC-USD/history/
  2. https://finance.yahoo.com/quote/ETH-USD/history/

Imports

Here I import plotly, seaborn, and matplotlib to create interactive plots. I also used sklean model for machine learning.

Data collection

I downloaded bitcoin and ethereum dataset from yahoo finance so I can easily create dataframes for them. Both datasets come with same catogories: Date, Open price, High price, Low price, Close Price, Adj Close price, and Volume.

Data Cleaning

Here I want to add a few more columns to our datasets, it will make our datasets more informatic and meet my requirements when I'm doing analysis. I added Year and month columns to have more specific date information in the datasets. I also added daily percentage change rate and Volatility per day columns.

Exploratory Analysis and Data Visualization

Now, I will visualize our data using plots, this can give us a better understanding of how bitcoin and Ethereum have moved in recent years, people can also find when was the high and low easily. I'll first plot the graphs from a large time scale to have an overview. I used Plotly here to make the plots, advantage of using Plotly is that it's very interactive. If I put my mouse on any point of the line, I will get more information about the value and index.

From the chart above for bitcoin closing price over time, we can see that there was a sharp rise in 2017 but dropped a lot and consolidated between 2018-2020. And from 2021, it had an exponential growth again and reached almost 70k. The price of bitcoin fluctuates a lot and there seems always to have a significant drop after a sharp rise.

From the plot above, Ethereum also had a sharp rise in 2017 and consolidated between 2018-2020, then it had exponential growth in 2021.

Now, we can combine two graphs and see the similarity of them on how prices change over time. Clearly, Bitcoin had larger "waves" compared to ethereum, this is because Bitcoin has more value so it's flucuate range of also larger. But from this plot, seems like there is some correlation between bitcoin and ethereum. We can do more analysis on it later and verify if our observation is true.

Box chart can help us identify the skewness of the data set and give us a good summary. So I made a box chart for Bitcoin and Ethereum. I tested their open price, close price, high price, and low price. From both box charts, I noticed boxes are all really close to the bottom. This means most of the time in the 6 years, Bitcoin and Ethereum stayed at a low price compared with their current price. This also points out that significant growth in 2021 has never happened before.

Now, let look at Bitcoin and Ethereum in one year period. let's see how box charts will look different compared with before. From the plots, we can tell boxes are located in the middle instead of the bottom, which means data are better distributed and our median is close to the average. This observation means bitcoin and Ethereum are sitting at a much higher price now compared to a few years ago.

The bar graphs below indicate the volume of bitcoin and Ethereum from 2015-2021. We can see that volume of Bitcoin increased approximately 100% every year starting from 2017 but slows down in 2021 with approximately 50% growth. Ethereum's growth rate is still 100% every year.

Now, we can use a heat map to calculate the correlation between Bitcoin and Ethereum. Heap map correlation range from -1 to 1. Values closer to 0 mean there is no linear relation between two variable, and values closer to 1 mean there is a positive correlation between them, and values closer to -1 means a negative correlation between them. I ended up getting 0.9295 as the correlation value, which means Bitcoin and Ethereum are highly correlated.

We can use the buy and hold strategy to analyze the return for both eth and btc over years. Buy and hold strategy is a passive investment strategy in which an investor makes a buy and holds them for a long period of time. We can calculate the return percentage using formula return_(t,0) = price_t / price_0 where t denotes a certain period and price_0 denotes the initial closing price

from the plot we got above, Ethereum seems to have more profits using buy and hold strategy.

Puting 100 dollars in 6 years ago, How much is it now?

So let's make an experiment to show how bitcoin and Ethereum would profit us using buy and hold strategy. Let's assume we bought 100 dollars each for bitcoin and Ethereum 6 years ago, how much does it worth today?

From the plot above, we were able to get 35.3 Ethereum and 0.36 Bitcoin with 100 dollars 6 years ago. let's see how much do they worth now?

From the plot we got, those Bitcoin would be worth approximately 17,000 dollars, and those Ethereum would be worth approximately 138,000 dollars. Did the result surprise you? By only investing 100 dollars, we can make a profit of over 10000 times profit by Ethereum. Bitcoin also had a good profit over the years but compared with Ethereum, Ethereum had a lot more potentials.

Prediction using Support Vector Regression

Now, let's make a prediction program on Bitcoin. I'll be using train_test_split procedure to estimate the performance of the machine learning algorithm and support vector regression to simple class separation. You can read more about SVM here. So what I will do is use previous data, and do a prediction on the most recent 100 days of bitcoin. And then I will check my accuracy of prediction.

I learned from this resource when doing the prediction

Now, we will use Support Vector regression model with radial basis function kernal to train the model. A kernal is a function that takes a nono-linear problem and tranforms it into a linear one. Gamma will affect the size of decision region. So when gamma is low, the curve for the decision boundary is also low and thus the decision region will be large.

Now using score function to give our prediciton a accuracy score, we got 0.8765 which means it's a pretty good prediction.

We can see that the predicted price we got was like the symmetric version to the actual price at 42,000. This is not ideal but the price different isn't too much.

Conclusion

Within this tutorial, I analyze the bitcoin and Ethereum in the last 6 years from their prices, volume, time, and other aspects. After doing the experiments and analyzing through plots, we know that Ethereum has more potential and would be more profitable compared with Bitcoin. Moreover, the skyrocket of the cryptocurrency market in 2021 also affects the overall price data a lot. During the machine learning part, I used the SVR model to predict bitcoin most recent 100 days prices, I was able to get a decent prediction.

Want to know more about Bitcoin or Ethereum, read the following resources:

How to buy Bitcoin? Click here

Is cryptocurrency a good investment? Click here

Ethereum price prediction Click here